Skip to content

Conversation

@fweilun
Copy link
Contributor

@fweilun fweilun commented Jul 22, 2025

Related: #53395

providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:106: error: Statement is unreachable [unreachable]
self.connections_prefix = connections_prefix

providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:110: error: Statement is unreachable [unreachable]
self.variables_prefix = variables_prefix

providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:114: error: Statement is unreachable [unreachable]
self.config_prefix = config_prefix

providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:151: error: Statement is unreachable [unreachable]
return None

providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:163: error: Statement is unreachable [unreachable]
return None

providers/microsoft/azure/src/airflow/providers/microsoft/azure/secrets/key_vault.py:175: error: Statement is unreachable [unreachable]
return None


All of the variables (connections_prefix, variables_prefix, config_prefix) are allowed to be None, as seen in existing test cases. However, the original code only implied string types, leading to unreachable MyPy errors.

We resolved this by:
• Explicitly annotating input arguments as str | None
• Using safe conditional initialization with

original:

if connections_prefix:
    self.connections_prefix = connections_prefix.rstrip(sep)
else:
    self.connections_prefix = connections_prefix
self.connections_prefix = connections_prefix
if isinstance(self.connections_prefix, str):
    self.connections_prefix.rstrip(sep)

providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/wasb.py:599: error: Statement is unreachable [unreachable]
conn = await sync_to_async(self.get_connection)(self.conn_id)

The code was flagged as unreachable by MyPy because self.blob_service_client was not annotated to allow None.
As a result, the following condition is always True from the type checker’s perspective:

if self.blob_service_client is not None:
    return self.blob_service_client

To fix this, we explicitly annotated the attribute to allow None:

self.blob_service_client: AsyncBlobServiceClient | None = None  # type: ignore

This makes the conditional logic valid and resolves the MyPy warning.


providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py:463: error: Statement is unreachable [unreachable]
request_information.content = data

Added bytes to the input type annotation to fix a type mismatch.


providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/synapse.py:129: error: Statement is unreachable [unreachable]
self.hook.cancel_job_run(

Annotated self.job_id as Any to match its default value None and resolve the type warning.


providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/msgraph.py:260: error: Statement is unreachable [unreachable]
if append_result_as_list_if_absent:

The is condition was unreachable due to the static type of results. Changing its annotation to Any resolves the issue.

@potiuk potiuk force-pushed the fix-unreachable-microsoft-azure branch from 4f7b60e to 987a561 Compare July 24, 2025 21:46
@eladkal eladkal requested a review from gopidesupavan July 27, 2025 10:21
Copy link
Member

@gopidesupavan gopidesupavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update WasbAsyncHook changes in different PR.

@fweilun
Copy link
Contributor Author

fweilun commented Jul 31, 2025

Hi, I’m currently abroad and will update the PR right after Aug 5. Will handle it as soon as I’m back — thanks!

@gopidesupavan
Copy link
Member

conflicts to resolve :)

@gopidesupavan
Copy link
Member

rebase ?

@fweilun fweilun force-pushed the fix-unreachable-microsoft-azure branch from 8d30873 to b74960e Compare August 12, 2025 04:26
@fweilun
Copy link
Contributor Author

fweilun commented Aug 12, 2025

@gopidesupavan Thanks for reviewing. I’ve updated accordingly.

@gopidesupavan gopidesupavan merged commit fa9fff4 into apache:main Aug 12, 2025
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants